﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using LitJson;
using MediaPortal.GUI.Library;
using MediaPortal.Plugins.Trailers.Common;

namespace MediaPortal.Plugins.Trailers.Providers {
  public abstract class TrailerProviderBase {

    public abstract string ProviderId();
    public abstract string ProviderName();
    public abstract string ProviderImage();

    public abstract Index GetIndex();
    public abstract Index GetIndex(string key);
    public abstract Trailer GetDetails(string key);

    //public abstract Index Search(string keyword);

    protected TrailerCollection Trailers;

    /// <summary>
    /// Initialize the provider by passing a TrailerCollection
    /// </summary>
    /// <param name="Collection"></param>
    public void Init(TrailerCollection Collection) {
      Trailers = Collection;
    }

    /// <summary>
    /// Get string data from url
    /// </summary>
    /// <param name="url"></param>
    /// <returns>page as string</returns>
    protected string GetString(string url) {
      string rtn = Common.Utils.GetWebData(url);
      return rtn;
    }


    /// <summary>
    /// Get XML data from url
    /// </summary>
    /// <param name="url"></param>
    /// <returns>XmlNode root</returns>
    protected XmlNode GetXml(string url) {
      XmlNode Root = Common.Utils.GetXml(url);
      return Root;
    }

    /// <summary>
    /// Get Json data from url
    /// </summary>
    /// <param name="url"></param>
    /// <returns>JsonData array</returns>
    protected JsonData GetJson(string url) {
      JsonData Data = Common.Utils.GetJson(url);
      return Data;
    }

  }
}
